<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="admin/common/html/tableHead :: head(~{::title},~{::link},~{::style})">

    <title th:text=${title}></title>
    <!-- 这儿引用单独的css link -->
    <!-- Ladda for Bootstrap 3按钮加载进度插件 -->
    <link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
    <!-- bootstrap-table表单样式 -->
    <link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
    <!-- 用户界面自定义css -->
    <link th:href="@{/static/admin/user/css/user-add.css}" rel="stylesheet"/>
    <style type="text/css"></style>
</head>

<body>

<div class="content-wrap">
    <div class="row">
        <div class="col-sm-12">
            <div class="nest" id="elementClose">
                <div class="">
                </div>
                <div class="body-nest" id="element">
                    <div class="panel-body">


                        <form  class="form-horizontal m" id="form-add"  >
                            <label class="col-sm-12" th:text="'考核'+${ExamPaper.name}" ></label>
                            <div class="form-group"   th:each="list,loopStatus: ${ExamPaper.qs}">

                                <input th:id = "eps[+(${loopStatus.index})+].paperId"   th:name = "eps[+(${loopStatus.index})+].paperId"  type="hidden" th:value="${ExamPaper.id}"/>
                                <input th:id = "eps[+(${loopStatus.index})+].questionId"   th:name = "eps[+(${loopStatus.index})+].questionId" type="hidden" th:value="${list.id}"/>
                                <label class="col-sm-3 control-label" th:text="'第'+${loopStatus.index+1}+'题:'+${list.name}"> </label>
                                <div class="col-sm-8">
                                   <!-- <option value="1">单选题</option>answer
                                    <option value="2">多选题</option>
                                    <option value="3">判断题</option>
                                    <option value="4">填空题</option>-->
                                    <div th:switch="${list.questionType}">
                                        <td th:case="1">
                                            <div th:each="m : ${list.qts}" class="radio radio-primary ">
                                                <input type="radio" th:id = "${m.id}"  th:name = "eps[+(${loopStatus.index})+].answer"   th:value="${m.code}">
                                                <label  th:for="${m.id}"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;" th:text="${m.name}"> </font></font></label>
                                            </div>

                                        </td>
                                        <td th:case="2">
                                            <div th:each="m : ${list.qts}" class="checkbox checkbox-primary">
                                                <input  class="sqcheckbox" th:id = "${m.id}"  th:name = "eps[+(${loopStatus.index})+].answer"   th:value="${m.code}"  type="checkbox">
                                                <label th:for="${m.id}" th:text="${m.name}"></label>
                                            </div>
                                        </td>

                                        <td th:case="*">
                                            <input class="form-control" type="text" th:name = "eps[+(${loopStatus.index})+].answer"/></td>
                                    </div>

                                </div>
                            </div>


                            <div class="form-group">
                                <div class="form-control-static col-sm-offset-9">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                    <button onclick="window.history.back(-1)" class="btn btn-danger" type="button">关闭</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">

</div>
<!-- bootstarp 表格 -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>


<!-- 弹窗 -->
<script  th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
<!-- 遮罩层 -->
<script  th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>
<!-- jqueryForm序列化 -->
<script  th:src="@{/static/js/jqueryFormSerializeJson.js}" type="text/javascript"></script>
<script type="text/javascript">

    $(function(){
        $(".MyDate").datetimepicker({
            format: "yyyy-mm-dd hh:00:00",
            startDate: new Date(),
            autoclose: true,
            todayBtn: true,
            language: 'zh-CN',
            initialDate:new Date(),
            minView: 1
        });

    })


    $("#form-add").validate({

        submitHandler:function(form){
            add();
        }
    });

    /**
     * 用户添加方法
     */
    function add() {
        var dataFormJson=$("#form-add").serialize();
        console.log(dataFormJson)
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/ExamPaperQuestionCustomerAnswerController/add",
            data : dataFormJson,
            async : false,
            error : function(request) {
               $.modal.alertError("系统错误");
            },
            success : function(data) {
                //$.operate.saveSuccess(data);
                $.modal.alertSuccess("答题成功");
            }
        });
    }


</script>


</body>


</html>
